/**
 * Created by codeczx on 2018/3/21.
 */
public class Test {

    public static void main(String[] args) {
        final LogService logService = new LogService();
        for (int i = 0; i < 5; i++) {
            new Thread(new Runnable() {
                private int i = 0;

                @Override
                public void run() {
                    try {
                        while (true) {
                            String logStr = Thread.currentThread().getName() + ":" + i++;
                            logService.log(logStr);
                            System.out.println(logStr);
                            Thread.sleep(1000);
                        }
                    } catch (InterruptedException e) {
                        System.out.println("worker thread interrupt");
                        e.printStackTrace();
                    }
                }
            }).start();
        }
        logService.start();
        try {
            Thread.sleep(3000);
            logService.stop();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
